Skip to content

[BugFix] Restore SHOW CREATE MATERIALIZED VIEW for sync MVs#73396

Merged
kevincai merged 1 commit into
StarRocks:mainfrom
kevincai:bugfix/fix-sync-mv-show-create
May 19, 2026
Merged

[BugFix] Restore SHOW CREATE MATERIALIZED VIEW for sync MVs#73396
kevincai merged 1 commit into
StarRocks:mainfrom
kevincai:bugfix/fix-sync-mv-show-create

Conversation

@kevincai
Copy link
Copy Markdown
Contributor

Sync MVs are mv indexes inside an OLAP table and are not registered as separate Tables in Database.idToTable / nameToTable. Since #43162 ("temporary table part-1") replaced the lookup in
showCreateInternalCatalogTable with MetaUtils.getSessionAwareTable, which throws SemanticException on miss, the existing fallback that scanned OLAP tables for a matching mv index has been unreachable - SHOW CREATE MATERIALIZED VIEW <sync_mv> has been failing with "Table ... is not found".

Catch SemanticException from the lookup and route MV-typed queries to a new findSyncMaterializedViewCreateStmt helper that performs the scan under DB READ (the indexNameToMetaId / indexMetaIdToMeta maps are HashMap-backed and mutated by ALTER, so the scan needs DB-wide exclusion). Non-MV queries rethrow the original "table not found" error unchanged.

Why I'm doing:

What I'm doing:

Fixes #issue

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • Parameter changes: default values, similar parameters but with different default values
  • Policy changes: use new policy to replace old one, functionality automatically enabled
  • Feature removed
  • Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function
    • This pr needs auto generate documentation
  • This is a backport pr

Bugfix cherry-pick branch check:

  • I have checked the version labels which the pr will be auto-backported to the target branch
    • 4.1
    • 4.0
    • 3.5
    • 3.4

@CelerData-Reviewer
Copy link
Copy Markdown

@codex review

@github-actions github-actions Bot requested a review from HangyuanLiu May 17, 2026 08:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Restores SHOW CREATE MATERIALIZED VIEW <sync_mv> support for legacy/sync materialized views (rollup-style MVs stored as MaterializedIndexMeta inside an OlapTable) by re-enabling a fallback resolution path when the regular catalog lookup fails.

Changes:

  • Catch SemanticException from MetaUtils.getSessionAwareTable and route MV-typed SHOW CREATE requests to a sync-MV scan over OLAP tables.
  • Add a shared helper to build the canonical 2-column SHOW CREATE MATERIALIZED VIEW result schema for both async and sync MV paths.
  • Add SQL regression coverage and a FE unit test covering SHOW CREATE MATERIALIZED VIEW for sync MVs and negative cases for SHOW CREATE TABLE/VIEW.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
fe/fe-core/src/main/java/com/starrocks/qe/ShowExecutor.java Restores sync-MV fallback by catching lookup miss and scanning OLAP tables under locks; unifies MV result schema.
fe/fe-core/src/test/java/com/starrocks/catalog/MaterializedViewTest.java Adds a unit test validating SHOW CREATE MATERIALIZED VIEW works for rollup/sync MVs.
test/sql/test_materialized_view/T/test_show_create_sync_materialized_view Adds SQL regression test for SHOW CREATE MATERIALIZED VIEW on a sync MV plus negative cases.
test/sql/test_materialized_view/R/test_show_create_sync_materialized_view Adds expected results for the new SQL regression test.

Comment thread fe/fe-core/src/main/java/com/starrocks/qe/ShowExecutor.java Outdated
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ad402e504f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread fe/fe-core/src/main/java/com/starrocks/qe/ShowExecutor.java Outdated
Comment thread fe/fe-core/src/main/java/com/starrocks/qe/ShowExecutor.java
@kevincai kevincai force-pushed the bugfix/fix-sync-mv-show-create branch 2 times, most recently from 41b406d to 61d59c6 Compare May 18, 2026 01:56
@kevincai kevincai requested a review from Copilot May 18, 2026 01:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread fe/fe-core/src/main/java/com/starrocks/qe/ShowExecutor.java Outdated
@kevincai kevincai force-pushed the bugfix/fix-sync-mv-show-create branch from 61d59c6 to b064d41 Compare May 18, 2026 02:43
@kevincai kevincai requested a review from Copilot May 18, 2026 02:57
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread fe/fe-core/src/main/java/com/starrocks/qe/ShowExecutor.java
@kevincai kevincai force-pushed the bugfix/fix-sync-mv-show-create branch from b064d41 to 3098beb Compare May 18, 2026 05:00
@kevincai kevincai requested a review from Copilot May 18, 2026 05:01
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread fe/fe-core/src/main/java/com/starrocks/qe/ShowExecutor.java
@kevincai kevincai force-pushed the bugfix/fix-sync-mv-show-create branch from 3098beb to bc5d555 Compare May 18, 2026 05:31
Sync MVs are mv indexes inside an OLAP table and are not registered as
separate Tables in Database.idToTable / nameToTable. Since StarRocks#43162
("temporary table part-1") replaced the lookup in
showCreateInternalCatalogTable with MetaUtils.getSessionAwareTable,
which throws SemanticException on miss, the existing fallback that
scanned OLAP tables for a matching mv index has been unreachable -
SHOW CREATE MATERIALIZED VIEW <sync_mv> has been failing with
"Table ... is not found".

Catch SemanticException from the lookup and route MV-typed queries to
a new findSyncMaterializedViewCreateStmt helper that performs the scan
under DB READ (the indexNameToMetaId / indexMetaIdToMeta maps are
HashMap-backed and mutated by ALTER, so the scan needs DB-wide
exclusion). Non-MV queries rethrow the original "table not found"
error unchanged.

Signed-off-by: Kevin Cai <kevin.cai@celerdata.com>
@kevincai kevincai force-pushed the bugfix/fix-sync-mv-show-create branch from bc5d555 to fe6b001 Compare May 18, 2026 07:14
@github-actions
Copy link
Copy Markdown
Contributor

[Java-Extensions Incremental Coverage Report]

pass : 0 / 0 (0%)

@github-actions
Copy link
Copy Markdown
Contributor

[FE Incremental Coverage Report]

pass : 40 / 44 (90.91%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 com/starrocks/qe/ShowExecutor.java 40 44 90.91% [956, 992, 999, 1000]

@github-actions
Copy link
Copy Markdown
Contributor

[BE Incremental Coverage Report]

pass : 0 / 0 (0%)

@kevincai kevincai requested review from luohaha and xiangguangyxg May 19, 2026 05:26
@kevincai kevincai requested a review from starrocks-xupeng May 19, 2026 05:26
@kevincai kevincai merged commit 4e35d9d into StarRocks:main May 19, 2026
86 of 91 checks passed
@kevincai kevincai deleted the bugfix/fix-sync-mv-show-create branch May 19, 2026 09:25
@github-actions
Copy link
Copy Markdown
Contributor

@Mergifyio backport branch-4.1

@github-actions
Copy link
Copy Markdown
Contributor

@Mergifyio backport branch-4.0

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 19, 2026

backport branch-4.1

✅ Backports have been created

Details

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 19, 2026

backport branch-4.0

✅ Backports have been created

Details

Cherry-pick of 4e35d9d has failed:

On branch mergify/bp/branch-4.0/pr-73396
Your branch is up to date with 'origin/branch-4.0'.

You are currently cherry-picking commit 4e35d9dc26.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   fe/fe-core/src/test/java/com/starrocks/catalog/MaterializedViewTest.java
	new file:   test/sql/test_materialized_view/R/test_show_create_sync_materialized_view
	new file:   test/sql/test_materialized_view/T/test_show_create_sync_materialized_view

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   fe/fe-core/src/main/java/com/starrocks/qe/ShowExecutor.java

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

wanpengfei-git pushed a commit that referenced this pull request May 19, 2026
…73396) (#73492)

Signed-off-by: Kevin Cai <kevin.cai@celerdata.com>
Co-authored-by: Kevin Cai <kevin.cai@celerdata.com>
wanpengfei-git pushed a commit that referenced this pull request May 19, 2026
…73396) (#73493)

Co-authored-by: Kevin Cai <kevin.cai@celerdata.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: kevincai <771299+kevincai@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants